/*package com.huitone.smspfm.core.config.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.huitone.smspfm.logger.ExtLogger;

import com.bin.common.utils.StringUtils;
import com.huitone.smspfm.context.utils.ContextPropertiesUtils;
import com.huitone.smspfm.context.utils.ContextUtils;
import com.huitone.smspfm.core.config.AbstractConfigurationLoader;
import com.huitone.smspfm.core.waterpipe.client.impl.SimpleGateLink;
import com.huitone.smspfm.core.waterpipe.client.impl.SimpleGateLinkRegister;
import com.huitone.smspfm.dao.oracle.BaseDao;
import com.huitone.smspfm.dao.oracle.GateDefDao;
import com.huitone.smspfm.dao.oracle.LinkSendCorpDao;
import com.huitone.smspfm.dao.oracle.LinkSendProDao;
import com.huitone.smspfm.dao.oracle.PriAllocDao;
import com.huitone.smspfm.dao.oracle.PriRuleDefDao;
import com.huitone.smspfm.dao.oracle.SmSignDao;
import com.huitone.smspfm.dao.oracle.SvrRouteRuleDao;
import com.huitone.smspfm.dao.oracle.UserRouteRuleDao;
import com.huitone.smspfm.dao.oracle.entity.GateDef;
import com.huitone.smspfm.dao.oracle.entity.LinkSendCorp;
import com.huitone.smspfm.dao.oracle.entity.LinkSendPro;
import com.huitone.smspfm.dao.oracle.entity.PriAlloc;
import com.huitone.smspfm.dao.oracle.entity.SmSign;
import com.huitone.smspfm.dao.oracle.entity.SvrRouteRule;
import com.huitone.smspfm.dao.oracle.entity.UserRouteRule;

@Deprecated
public class OracleConfigurationLoader extends AbstractConfigurationLoader {
	
	private Logger log = Logger.getLogger(OracleConfigurationLoader.class);
	
	public static enum Configs {
		
		*//**
		 * 短信签名,以Map方式存储,key=srvNode:serviceCode, value=签名内容
		 *//*
		srvnode_servicecode_sign,
		*//**
		 * 以Map方式存储,key=serviceCode, value=Set<gate_link_id>
		 *//*
		service_code_and_gli,
		*//**
		 * 以Set方式存储,value=province:gate_link_id
		 *//*
		link_send_pro_pl_set,
		*//**
		 * 以Set方式存储,value=mobil_corp:gate_link_id
		 *//*
		link_send_corp_pl_set,
	}
	
	List<BaseDao<?>> list = null;
	
	public OracleConfigurationLoader() {
		super();
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public synchronized void load() {
		
		log.info("开始加载配置信息...");
		
		if (list == null) {
			new RuntimeException("配置信息的数据库连接实例列表为空！");
		}
		
		for (BaseDao<?> bd:list) {
			
			// 获取所有配置信息到内存中
			List<?> allObj = bd.getAllObj();
			setConfiguration(bd.getTableName(), allObj);
			
			// 按业务端/业务编码，选择短信网关
			if (bd instanceof SvrRouteRuleDao) {
				if (allObj != null) {
					Map<String, String> map = new HashMap<>();
					List<SvrRouteRule> srlist = (List<SvrRouteRule>) allObj;
					for (SvrRouteRule sr:srlist) {
						
						if (StringUtils.isEmpty(sr.getSvrNode()) && StringUtils.isEmpty(sr.getServiceCode())) continue;
						
						String key = StringUtils.objToString(sr.getSvrNode()) + ":" + StringUtils.objToString(sr.getServiceCode());
						String value = sr.getGateLinkId();
						map.put(key, value);
					}
					setConfiguration(ContextPropertiesUtils.getProperty("svr.route.map.gatelink.id"), map);
				}
			}
			
			// 将对应业务端/业务编码对应的优先级以Map的方式保存（主要是提高处理效率）
			if (bd instanceof PriAllocDao) {
				if (allObj != null) {
					Map<String, Integer> map = new HashMap<>();
					List<PriAlloc> palist = (List<PriAlloc>) allObj;
					for (PriAlloc pa:palist) {
						String key = StringUtils.objToString(pa.getSvrNode()) + ":" + StringUtils.objToString(pa.getServiceCode());
						Integer value = pa.getLevel();
						map.put(key, value);
					}
					setConfiguration(ContextPropertiesUtils.getProperty("pri.alloc.level"), map);
				}
			}
			
			// 用户号码号段匹配,长号段优先
			if (bd instanceof UserRouteRuleDao) {
				if (allObj != null) {
					List<UserRouteRule> palist = (List<UserRouteRule>) allObj;
					Collections.sort(palist, new Comparator<UserRouteRule>() {

						@Override
						public int compare(UserRouteRule o1, UserRouteRule o2) {
							
							if (StringUtils.objToString(o1.getSectionNo()).length() > StringUtils.objToString(o2.getSectionNo()).length()) {
								return -1;
							} else if (StringUtils.objToString(o1.getSectionNo()).length() < StringUtils.objToString(o2.getSectionNo()).length()) {
								return 1;
							} else {
								return 0;
							}
						}
					});
					setConfiguration(bd.getTableName(), palist);
				}
			}
			
			// 获取优先值定义表中，优先级最低的那条记录，保存到内存
			if (bd instanceof PriRuleDefDao) {
				setConfiguration(ContextPropertiesUtils.getProperty("pri.rule.def.min.level.obj"), ((PriRuleDefDao)bd).getMinLevel());
			}
			
			// 获取网关连接并做登记
			if (bd instanceof GateDefDao) {
				if (allObj != null) {
					List<GateDef> defs = allObj != null ? (ArrayList<GateDef>) allObj : new ArrayList<>(); 
					SimpleGateLinkRegister gateLinkRegister = ContextUtils.getBean2(SimpleGateLinkRegister.class);
					gateLinkRegister.clear();
					for (GateDef def:defs) { // 登记GateLink
						if (def == null) continue;
						gateLinkRegister.register(def.getGateLinkId(), new SimpleGateLink(def));
					}
				}
			}
			
			// 签名,将对应业务端/业务编码对应的签名以Map的方式保存（主要是提高处理效率）
			if (bd instanceof SmSignDao) {
				if (allObj != null) {
					List<SmSign> list = allObj != null ? (ArrayList<SmSign>) allObj : new ArrayList<>();
					Map<String, String> map = new HashMap<>();
					for (SmSign ss:list) {
						String key = StringUtils.toString(ss.getSrvNode()) + ":" + StringUtils.toString(ss.getServiceCode());
						String value = StringUtils.toString(ss.getSignContent());
						map.put(key, value);
					}
					setConfiguration(Configs.srvnode_servicecode_sign, map);
				}
			}
			
			// serviceCode对应的通道ID
			if (bd instanceof SvrRouteRuleDao) {
				List<SvrRouteRule> list = allObj != null ? (ArrayList<SvrRouteRule>) allObj : new ArrayList<>();
				Map<String, Set<String>> map = new HashMap<>();
				for (SvrRouteRule sr:list) {
					String serviceCode = sr.getServiceCode();
					String gateLinkId = sr.getGateLinkId();
					if (map.containsKey(serviceCode)) {
						map.get(serviceCode).add(gateLinkId);
					} else {
						Set<String> set = new HashSet<String>();
						set.add(gateLinkId);
						map.put(serviceCode, set);
					}
				}
				setConfiguration(Configs.service_code_and_gli, map);
			}
			
			// 可发送省份:通道ID
			if (bd instanceof LinkSendProDao) {
				List<LinkSendPro> list = allObj != null ? (ArrayList<LinkSendPro>) allObj : new ArrayList<>();
				Set<String> set = new HashSet<String>();
				for (LinkSendPro lsp:list) {
					set.add(StringUtils.toString(lsp.getProvince()) + ":" + StringUtils.toString(lsp.getGateLinkId()));
				}
				setConfiguration(Configs.link_send_pro_pl_set, set);
			}
			// 可发送运营商:通道ID
			if (bd instanceof LinkSendCorpDao) {
				List<LinkSendCorp> list = allObj != null ? (ArrayList<LinkSendCorp>) allObj : new ArrayList<>();
				Set<String> set = new HashSet<String>();
				for (LinkSendCorp lsc:list) {
					set.add(StringUtils.toString(lsc.getMobilCorp()) + ":" + StringUtils.toString(lsc.getGateLinkId()));
				}
				setConfiguration(Configs.link_send_corp_pl_set, set);
			}
		}
		
		log.info("配置信息加载完成！");
	}
	
	@Override
	public synchronized void reload() {
		
		log.info("重新加载配置信息...");
		
		this.clearConfiguration();
		
		load();
		
		log.info("重新加载配置信息完成！");
	}

	public void setList(List<BaseDao<?>> list) {
		this.list = list;
	}
}
*/